<?php
    include __DIR__ . "/config/cors.php";
    $url = @$_GET['url'];
    if (!isset($url)){
        echo json_encode([
            "code" => 201,
            "msg" => "文件删除失败" . $url . "///////"
        ]);
        exit;
    }

    $local_path = __DIR__ . "/upload/";
    $file = basename($url);
    $need = $local_path . $file;
    // file_exists 判断文件是否存在
    // unlink 删除文件
    if (file_exists($need)){
        unlink($need);
        echo json_encode([
            "code" => 200,
            "msg" => "文件删除成功"
        ]);
    }else{
        echo json_encode([
            "code" => 202,
            "msg" => "文件删除失败"
        ]);
    }

?>